package com.guo.MyController;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import com.guo.model.User;

@Controller
@RequestMapping("/acc")
public class UserController extends AbstractController {

	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		System.out.println(request.getServletContext().getAttribute("myObject"));
		
		User user1 = new User("小王",1);
		User user2 = new User("老王",30);
		List<User> lists = new ArrayList<User>() {{
				add(user1);
				add(user2);
		}};
//		if (1 == 1)
//			throw new Exception("");
		return new ModelAndView("my", "users", lists);
	}

}
